﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace game
{
    class MineLauncher : Weapon
    {
        public MineLauncher(Scene scene, Ship shooter)
            : base(scene, shooter)
        {
            shotIntervalMs = 5000;
        }

        public override bool Shoot(int layerIndex, Vector3 position, Vector3 rotation)
        {
            if (!CanShoot())
            {
                return false;
            }

            Vector3 offset = -3500.0f * Vector3.Transform(
                    Vector3.Forward, Matrix.CreateRotationY(rotation.Y));

            position += offset;

            scene.AddObject(
                ProximityMine.Create(scene, shooter, layerIndex, position, rotation), layerIndex);

            timeFromShotMs = 0;

            return true;
        }

        public override bool Shoot(int layerIndex, Vector3 position, Vector3 rotation, Vector3 velocity)
        {
            if (!CanShoot())
            {
                return false;
            }

            Vector3 offset = -3500.0f * Vector3.Transform(
                    Vector3.Forward, Matrix.CreateRotationY(rotation.Y));

            position += offset;

            Projectile p = ProximityMine.Create(scene, shooter, layerIndex, position, rotation);
            p.InitialVelocity = velocity;
            scene.AddObject(
                p, layerIndex);

            timeFromShotMs = 0;

            return true;
        }
    }
}
